/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package frm.billingAndPaymentProcessing.managedbean;

import frm.billingAndPaymentProcessing.entity.ReceiptEntity;
import frm.billingAndPaymentProcessing.session.ReceiptSessionBean;
import java.io.IOException;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;

/**
 *
 * @author xhx
 */
@ManagedBean(name="viewAllReceiptManagedBean")
@ViewScoped
public class ViewAllReceiptManagedBean {
private ReceiptEntity receipt;

@EJB
ReceiptSessionBean receiptSessionBean;
    /** Creates a new instance of ViewAllReceiptManagedBean */
    public ViewAllReceiptManagedBean() {
        receipt = new ReceiptEntity();
    }
    
    public List<ReceiptEntity> getAllReceipt(){
      List<ReceiptEntity> receiptList  = receiptSessionBean.getAllReceipt();
      return receiptList;
    }
    
    public void viewReceipt(ReceiptEntity receiptEntity) throws IOException{
        receipt = receiptEntity;
       FacesContext.getCurrentInstance().getExternalContext().getFlash().put("receipt", receipt);
       FacesContext.getCurrentInstance().getExternalContext().redirect("displayReceipt.xhtml");
    }
    public ReceiptEntity getReceipt() {
        return receipt;
    }

    public void setReceipt(ReceiptEntity receipt) {
        this.receipt = receipt;
    }
}
